#!/bin/bash

# =============================================
# 终极测试方案 - 直接修改容器内配置文件
# =============================================

CONTAINER_ID="efcd68837652"

# 直接修改容器内的配置文件
docker exec $CONTAINER_ID /bin/bash -c 'cat > /app/config_env.py << EOF
BASE_URL = "https://zentao.ashermed.com/api.php/v1"
USERNAME = "shawn.qian"
PASSWORD = "James028120^"
TOKEN = None
EOF'

# 3. 执行测试
RESPONSE=$(docker exec -i $CONTAINER_ID python3 -c "
import logging
logging.basicConfig(level=logging.INFO)

try:
    from service.user_service import list_all
    print(list_all())
except Exception as e:
    print(f'ERROR: {str(e)}')
")

# 输出结果
echo -e "\n=== 测试结果 ==="
if [[ "$RESPONSE" == ERROR* ]]; then
    echo -e "❌ 测试失败\n错误详情："
    echo "$RESPONSE"
else
    echo -e "✅ 测试成功\n用户列表："
    echo "$RESPONSE"
fi
